#include "HNActivityScence.h"
#include "Game/GameLib.h"
#include "Scene/HNScenceManager.h"

FV_SINGLETON_STORAGE(HNActivityScence);

HNActivityScence::HNActivityScence()
{
	init();
}
HNActivityScence::~HNActivityScence()
{

}
bool HNActivityScence::init()
{
	if (!Node::init())
	{
		return false;
	};

	_layout = CSLoader::createNode("activityLayer.csb");
	addChild(_layout);

	auto btn = (Button*)_layout->getChildByName("Button_close");
	btn->addTouchEventListener(CC_CALLBACK_2(HNActivityScence::BtnCallBack, this));
	return true;
}
void HNActivityScence::EnterScence()
{
	
}
void HNActivityScence::hideAll()
{
	setVisible(false);
}

void HNActivityScence::BtnCallBack(Ref* pSender, Widget::TouchEventType touchtype)
{
	Button* btn = (Button*)pSender;
	if (!btn) return;

	switch (touchtype)
	{
		case Widget::TouchEventType::ENDED:
		{
			if (btn->getName().compare("Button_close") == 0)
			{
				GameManagerBase::InstanceBase().disconnectServer();
				hideAll();
			}
		}
	}
}
